﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_0812159_0812164._Default" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<html xmlns="http://www.w3.org/1999/xhtml" onload="checkLogin()">

<head runat="server">
    <title>Google Map</title>

    <link type="text/css" rel="stylesheet" href="style.css" />
    <link type="text/css" rel="stylesheet" href="jquery.treeview.css" />
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="scripts/jquery-1.4.1.js" ></script>
    <script type="text/javascript" src="scripts/gmap.js"></script>
    <script type="text/javascript" src="scripts/gears_init.js"></script>    
    <script type="text/javascript" src="scripts/popupmenu.js"></script>
    <script type="text/javascript" src="scripts/utility.js"></script>

    <script type="text/javascript" src="scripts/action.js"></script>
    <script type="text/javascript" language="javascript">
        function checkLogin(){
            var username= '<%=Session["username"]%>';
            alert("check");
            if(username){
            alert(username);
                document.getElementById("sign").style.display = 'block';
                document.getElementById("unsign").style.display = 'none';
              
            }            
        }        
    </script>
</head>

<body onload="initialize()">
    <form id="form1" method="post" runat="server" style="width:100%;">
        <!--<input type="button" value="GetShare" onclick="javascript:doGetShare('user2')"/>-->
    
    <asp:LinkButton ID="l1" PostBackUrl="~/Default.aspx" runat="server" Text=""/>
    <input id="lbUserName" type="hidden"/>
    
    <div id="header">
        <div id="logo">Google Map</div>
        <div id="frmLogin"> 
            <div id="sign">
                <% if (Session["username"] != null){                   
                       %>
                       <%=Session["username"]%> | <a href='javascript:doLogout()'>Signout</a>                       
                 <%} %>
            </div>
                      
            <div id="unsign">
                <%if (Session["username"] == null){ %>
                <input id="txtUserName" class="inputLogin" type="text" onblur="return RemoveUserText()" onclick="return TempUserText()" value="Tên đăng nhập"/>&nbsp;
                <input id="txtPassword" class="inputLogin" type="password" onblur="return RemovePassText()" onclick="return TempPassText()" value="password"/>             
                <input id="cmdSubmit" type="button" class="button" value="Đăng nhập" onclick="javascript:doLogin()"/>
                <a href="Register.aspx">Đăng ký</a>
                <label id="lblMessage"></label>
                <%} %>
            </div>
        </div>
    </div>        

    <div id="content">        
        <div id="content_left">           
            <asp:Panel ID="pSearch" runat="server">
                <div class="windows">  
                    <div class="capture">Tìm kiếm</div>
                    <input id="txtSearch" style="width:75%" type="text"/>
                    <button id="btSearch" class="button" type="button" onclick="doSearchLocation()">Tìm</button>
                    
                    <div id="pSearchResults" class="alignLeft" style="margin:0 10px 0 10px;"></div>
                </div>                   
            </asp:Panel>
            
            <asp:Panel ID="pSearch2" runat="server">
                <div class="windows">  
                    <div class="capture">Tìm địa điểm gần nhất</div>
                    <input id="txtSearch2" style="width:75%" type="text"/>                        
                    <asp:DropDownList ID="ddlCatelogy2" style="width:75%" runat="server"></asp:DropDownList><br />                        
                    Số lượng kết quả: <br/>
                    <asp:DropDownList ID="ddlNumOfResults" style="width:75%" runat="server"></asp:DropDownList><br />                        
                    
                    <button id="btSearch2" class="button" type="button" onclick="doSearchNearLocation()">Tìm</button>
                    <button id="Button1" class="button" type="button" onclick="doCancel()">Hủy</button>
                    <div id="pSearch2Results" class="alignLeft" style="margin:0 10px 0 10px;"></div>
                </div>                   
            </asp:Panel>
            
            <asp:Panel ID="pShared" runat="server">
                <div class="windows" style="text-align:left">
                    <div class="capture">Địa điểm được chia sẻ:</div>
                    <div id="dShare"></div>
                </div>
		     </asp:Panel>
            
            <asp:Panel ID="pTreeView" runat="server">
                <div class="windows" style="text-align:left">
                    <div class="capture">Địa điểm đã lưu</div>
                    <div id="treeLocation"></div>
                </div>
		     </asp:Panel>
            <input type="button" name="name" value="Thêm địa điểm" class="button" onclick="selectPlace()"/><br />
        
            <asp:Panel ID="pAddGuide" runat="server">         
                <div class="windows" style="text-align:left;">
                    <div class="capture">Thêm địa điểm</div>           
                    <b>Hướng dẫn</b><br />
                    Click lên bản đồ để thêm địa điểm<br/>Có thể kéo thả marker sau khi click
                </div>
            </asp:Panel>
        
            <asp:Panel ID="pEdit" runat="server" style="display:none">
                <div class="windows" style="text-align:center;">  
                    <div class="capture">Thêm địa điểm</div>
                    <div class="name">Tên địa điểm: *</div>
                    <input id="txtNameLocation" type="text" style="width:75%" runat="server"/>
                    <div class="name">Địa chỉ:</div>
                    <input id="txtAddress" type="text" style="width:75%" runat="server"/>
                    <div class="name">Mô tả:</div>
                    <input id="txtDescription" type="text" style="width:75%" runat="server"/>
                    <div class="name">Danh mục:</div>
                    <asp:DropDownList ID="listCatalog" style="width:75%;" runat="server"></asp:DropDownList><br />                        
                    <button id="btAdd"      class="button left" type="button" onclick="doAddLocation()">Thêm</button>
                    <button id="btDelete"   class="button left" type="button" onclick="doDeleteLocation()">Xóa</button>
                    <button id="btEdit"     class="button left" type="button" onclick="doEditLocation()">Sửa</button>
                    <button id="btCancel"   class="button left" type="button" onclick="doCancel()">Hủy</button>                    
                </div>
                
                <input id="lbLatLng" type="hidden" runat="server" value="-1"/>
                <input id="lbLat" type="hidden" runat="server"  value="-1"/>
                <input id="lbLng" type="hidden"  runat="server" value="-1"/>
                <input id="lbIdLocation" type="hidden"  runat="server" value="-1"/>
            </asp:Panel>
            
            <asp:Panel ID="pShare" runat="server" style="display:block">
                 <div class="windows">  
                    <div class="capture">Chia sẻ địa điểm</div>
                    Chia sẻ địa điểm này với:<br />
                    <asp:DropDownList ID="ddlUserShare" style="width:75%" runat="server"></asp:DropDownList><br />                        
                    <button id="btShare"       class="button" type="button" onclick="doShareLocation()">Chia sẻ</button>
                    <button id="btCancelShare" class="button" type="button" onclick="doCancelShareLocation()">Hủy</button>
                </div>
            </asp:Panel>
        </div>
            
        <div id="centerSplit">
            <a id="moveicon" class="moveicon" onclick="moveIconClick()"></a>
        </div>
        
        <div id="content_right">
            <div id="map_canvas"></div>
        </div>
    </div> 
    
    <div id="pPopupShare" class="popupShare">         
        <div class="capture">Địa điểm được chia sẻ
            <input type="button" class="button icon" value="x" onclick="closePopupShare()"/>
        </div>
        <div id="dShareContent" class="content">
        <%--
            <div class="item" id="var_idShare">
                <div class="info">nguyenhiep chia se dia diem aaaa</div>
                <div class="button right" onclick='javascript:deny(var_idShare)'>Bỏ qua</div>
                <div class="button right" onclick='javascript:accept(var_idShare, var_idLocation)'>Chấp nhận</div>
            </div>
            --%>
        </div>
    </div>
     
    </form>
<script type="text/javascript">
    var s = '<%=Session["username"]%>';
	//alert('ready_'+s);
	if(s!=null && s!=''){
	    hideAllPanel();
	    showControl('pSearch');
	    reloadTreeLocationByUserName(s);
	    google.maps.event.addListener(map, "rightclick",function(event){showContextMenu(event.latLng);});  
        var a = document.getElementById(pTreeView);
        a.style.display ='block';
    }else{
        hideAllPanel();
	    showControl('pSearch');
    }
</script> 


   
</body>

</html>
